import { mapActions, mapMutations } from 'vuex'
const ACTION_PREFIX = module.id; // 设置action前缀确保type的唯一性

//mutations
export const setUserAddressList = `${ACTION_PREFIX}/setUserAddressList`;
export const setRegionList = `${ACTION_PREFIX}/setRegionList`;
export const setMyOrderListData = `${ACTION_PREFIX}/setMyOrderListData`;
export const setShouldRefreshMyOrderList = `${ACTION_PREFIX}/setShouldRefreshMyOrderList`;
// actions
// 上传头像
export const UPLOAD_AVATAR = `${ACTION_PREFIX}/UPLOAD_AVATAR`;
// 修改用户
export const UODATE_MEMBER = `${ACTION_PREFIX}/UOLOAD_MEMBER`;
export const GET_USER_SERVICE_PROTOCOL = `${ACTION_PREFIX}/GET_USER_SERVICE_PROTOCOL`;

export const GET_REGION_LIST = `${ACTION_PREFIX}/GET_REGION_LIST`;
export const GET_USER_ADDRESS_LIST = `${ACTION_PREFIX}/GET_USER_ADDRESS_LIST`;
export const ADD_DELETE_USER_ADDRESS = `${ACTION_PREFIX}/ADD_DELETE_USER_ADDRESS`;
export const UPDATE_USER_ADDRESS = `${ACTION_PREFIX}/UPDATE_USER_ADDRESS`;
export const LOAD_MY_ORDER_LIST = `${ACTION_PREFIX}/LOAD_MY_ORDER_LIST`;
export const LOAD_MY_ORDER_DETAIL = `${ACTION_PREFIX}/LOAD_MY_ORDER_DETAIL`;
export const USER_CONFIRM_RECERVE_ORDER = `${ACTION_PREFIX}/USER_CONFIRM_RECERVE_ORDER`;

// 添加微信订阅消息
export const ADD_WX_SUBSCRIBE_MESSAGE = `${ACTION_PREFIX}/ADD_WX_SUBSCRIBE_MESSAGE`;
export const INSERT_SHOP_COMMENT = `${ACTION_PREFIX}/INSERT_SHOP_COMMENT`;

export const LOAD_INTEGRAL_LIST = `${ACTION_PREFIX}/LOAD_INTEGRAL_LIST`;

export const mutations = mapMutations({
	setShouldRefreshMyOrderList,
})

export default mapActions({
	uploadAvatar: UPLOAD_AVATAR,
	updataMember: UODATE_MEMBER,
	//
	getUserServiceProtocol: GET_USER_SERVICE_PROTOCOL,
	// 地址
	getRegionList: GET_REGION_LIST,
	getUserAddressList: GET_USER_ADDRESS_LIST,
	addDeleteUserAddress: ADD_DELETE_USER_ADDRESS,
	updateUserAddress: UPDATE_USER_ADDRESS,
	// 订单
	loadMyOrderList: LOAD_MY_ORDER_LIST,
	loadMyOrderDetail: LOAD_MY_ORDER_DETAIL,
	userConfirmRecerveOrder: USER_CONFIRM_RECERVE_ORDER,
	addWXSubscribeMessage: ADD_WX_SUBSCRIBE_MESSAGE,
	// 评论
	inertShopComment: INSERT_SHOP_COMMENT,
	// 积分明细
	loadIntegralList: LOAD_INTEGRAL_LIST,
})